#ifndef CONVERSE_CONVERSEABSTRACTMESSAGE_H
#define CONVERSE_CONVERSEABSTRACTMESSAGE_H


#include <QObject>
#include <QVariant>
#include <QVariantMap>
#include <QPointer>


namespace Account {
class Member;
}

namespace Converse {

class AbstractConversation;

class AbstractMessage : public QObject
{
    Q_OBJECT
public:
    enum Type {
        TextType = 0,
        StickerType = 1,
        PhotoType = 2,
        VoiceType = 3,
        VideoType = 4,
        LocationType = 5,
        FilmType = 6,
        Mp3Type = 7,
        NewsType = 8,
        ContactType = 9,
        BookType = 10,
        BlogType = 11,
        UnknownType = 12
    };

public:
    AbstractMessage(qint64 id,
                    qint64 sendingId,
                    const AbstractConversation &conversation,
                    qint64 createdTime,
                    qint64 receivedTime,
                    int32_t senderId,
                    qint64 receiverId,
                    QObject *parent = 0);

private:
    qint64 m_id;
    qint64 m_sendingId;
    const AbstractConversation &m_conversation;
    qint64 m_createdTime;
    qint64 m_receivedTime;
    int32_t m_senderId;
    qint64 m_receiverId;

public:
    virtual Type type() const = 0;
    virtual const QString &message() const = 0;
    virtual QVariant extra() const = 0;

public:
    inline void setId(qint64 id) {
        m_id = id;
    }

    inline qint64 id() const {
        return m_id;
    }

    inline void setLocalId(qint64 localId) {
        m_sendingId = localId;
    }

    inline qint64 sendingId() const {
        return m_sendingId;
    }

    inline qint64 receiverId() const {
        return m_receiverId;
    }

    inline void setCreatedTime(qint64 createdTime) {
        m_createdTime = createdTime;
    }

    inline qint64 createdTime() const {
        return m_createdTime;
    }

    inline void setReceivedTime(qint64 receivedTime) {
        m_receivedTime = receivedTime;
    }

    inline qint64 receivedTime() const {
        return m_receivedTime;
    }

    inline const AbstractConversation &conversation() const {
        return m_conversation;
    }


    int32_t senderId() const;

    QVariant toVariant() const;
};

} // namespace Converse

#endif // CONVERSE_CONVERSEABSTRACTMESSAGE_H
